package xyz.xtt.schedule.constants;

/**
 * 通通链操作错误信息类
 */
public enum ErrorMessage {

	UNKNOWN_ERROR(9999, "unknown error");

	private Integer code;

	private String message;

	private ErrorMessage(Integer code, String message) {
		this.code = code;
		this.message = message;
	}

	public String getMessage() {
		return message;
	}

	public Integer getCode() {
		return code;
	}

	public static String getMessage(Integer code) {
		for (ErrorMessage error : ErrorMessage.values()) {
			if (error.code.equals(code)) {
				return error.message;
			}
		}
		return null;
	}

	public static String getMessage(ErrorMessage errorMessage) {
		for (ErrorMessage error : ErrorMessage.values()) {
			if (error.code.equals(errorMessage.code)) {
				return error.message;
			}
		}
		return null;
	}
}
